﻿using System.Collections.Generic;
using System.Linq;

namespace KL.Standard.Model.ViewModels.Queue
{
    /// <summary>
    /// 账户授权
    /// </summary>
    public class OutSysAccountAuthorVM
    {
        /// <summary>
        /// 账户信息
        /// </summary>
        public string loginID { get; set; }

        /// <summary>
        /// 外部系统的代码
        /// </summary>
        public string sysCode { get; set; }

        /// <summary>
        /// 所选择的菜单和功能的id
        /// </summary>
        public List<string> checks { set; get; }

        /// <summary>
        /// 获取被选择的菜单
        /// </summary>
        public List<long> menuIDs
        {
            get
            {
                if (checks != null && checks.Count > 0)
                {
                    return checks.Where(i => i.StartsWith("M"))
                        .Select(i => long.Parse(i.Replace("M", "")))
                        .ToList();
                }

                return null;
            }
        }

        /// <summary>
        /// 获取被选择的功能
        /// </summary>
        public List<long> funIDs
        {
            get
            {
                if (checks != null && checks.Count > 0)
                {
                    return checks.Where(i => i.StartsWith("F"))
                        .Select(i => long.Parse(i.Replace("F", "")))
                        .ToList();
                }

                return null;
            }
        }
    }
}